package io.gitee.chearnee.fw.datasecurity.mybatisplus.builder;


import io.gitee.chearnee.fw.datasecurity.core.resolver.MethodEncryptResolver;
import io.gitee.chearnee.fw.datasecurity.core.resolver.SimpleMethodEncryptResolver;
import io.gitee.chearnee.fw.datasecurity.mybatis.builder.MybatisMethodCryptMetadataBuilder;

import java.lang.reflect.Method;
import java.util.Map;

/**
 * Mybatis Plus的MethodCryptMetadata 的建造者
 *
 * @author kamjin1996
 */
public class MybatisPlusMethodCryptMetadataBuilder extends MybatisMethodCryptMetadataBuilder {

    public MybatisPlusMethodCryptMetadataBuilder(Method runningMethod) {
        super(runningMethod);
    }

    @Override
    protected MethodEncryptResolver buildEncryptResolver(Method m, Object parameterObject) {
        if (!(parameterObject instanceof Map)) {
            return new SimpleMethodEncryptResolver();
        }
        return super.buildEncryptResolver(m, parameterObject);
    }
}
